package com.bravo.mvpkotlin.ui.main

import com.bravo.mvpkotlin.data.DataManager
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by Administrator on 2017/6/22 0022.
 */

class MainPersenter (val mainViews: MainViews, val dataManager: DataManager){

    fun getUser(key: String) {
        dataManager.getUsers(key)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnSubscribe { mainViews.startLoading() }
                .doOnError { mainViews.stopLoading() }
                .subscribe { mainViews.showUsers(it) }
    }
}